package de.shortys.myhome.api.view.tree;

import java.awt.Cursor;

import javax.swing.JTree;

public class ModuleViewTree extends JTree {

	private static final long serialVersionUID = 1L;

	private ModuleViewTreeModel model;

	public ModuleViewTree() {
		initialize();
	}

	public ModuleViewTreeNode getRoot() {
		return (ModuleViewTreeNode) model.getRoot();
	}

	public void reload() {
		reload(getRoot());
	}

	public void reload(ModuleViewTreeNode node) {
		model.reload(node);
	}

	private void initialize() {
		model = new ModuleViewTreeModel(new ModuleViewTreeNode("root", null));
		setModel(model);
		setCursor(new Cursor(Cursor.HAND_CURSOR));
		setRowHeight(25);
		setToggleClickCount(100);
		setRootVisible(false);
		setCellRenderer(new ModuleViewTreeCellRenderer());
	}
}
